<template>
	<view class="page">
		<view class="DrawerClose" :class="{ 'show': modalName === 'viewModal' }" @tap="hideModal">
			<text class="cuIcon-pullright"></text>
		</view>
		<scroll-view scroll-y class="DrawerWindow" :class="{ 'show': modalName === 'viewModal' }" style="height: 90vh;">
			<view class="cu-list menu card-menu margin-top-xl margin-bottom-xl shadow-lg" >
				<view class="cu-item arrow" v-for="(item,index) in list" :key="index" @click="choose(item)">
					<view class="content">
						<text class="text-grey" :style="{ 'background-image': 'url(' + item.img + ')' }"></text>
						<text class="text-grey">{{ item.title }}</text>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {getMypost} from '@/store/api.js'
	export default {
		mounted() {
			uni.$on('showList', value => {
				this.showModal('viewModal')
				this.userid=value
			})
			getMypost(1, 2000).then(res => {
				// console.log('我是drawers')
				const ress=JSON.parse(res)
				// console.log(ress.data)
				ress.data.rows.forEach(item => {
					// const content = getcontent(item.id)
					this.list.unshift({
						// img: item.postAvatar,
						title: item.title,
						mesid: item.id,
					})
				})
			}).catch(err => {
				console.log(err)
			})
		},
		data() {
			return {
				userid:'',
				list:[],
				StatusBar: null,
				CustomBar: null,
				Custom: null,
				hasUserInfo: false,
				canIUse: false,
				TabCur: 1,
				scrollLeft: 0,
				modalName: null
			};
		},
		methods: {
			showModal(target) {
				this.modalName = target;
			},
			hideModal() {
				this.modalName = null;
			},
			tabSelect(e) {
				console.log(e);
				this.TabCur = e.currentTarget.dataset.id;
				this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60;
			},
			choose(item){
				console.log(item)
				uni.$emit('backkk',JSON.stringify({
					userid:this.userid,
					title:item,
					mesid:item.mesid
				}))
				this.showModal('')
			}
		}
	};
</script>

<style scoped>
	.page {
		background-image: var(--gradualBlue);
		width: 100vw;
		overflow: hidden;
	}

	.DrawerPage {
		position: fixed;
		width: 100vw;
		height: 100vh;
		left: 0vw;
		background-color: #f1f1f1;
		transition: all 0.4s;
	}

	.DrawerPage.show {
		transform: scale(0.9, 0.9);
		left: 85vw;
		box-shadow: 0 0 60rpx rgba(0, 0, 0, 0.2);
		transform-origin: 0;
	}

	.DrawerWindow {
		position: absolute;
		width: 85vw;
		height: 100vh;
		left: 0;
		top: 0;
		transform: scale(0.9, 0.9) translateX(-100%);
		opacity: 0;
		pointer-events: none;
		transition: all 0.4s;
	}

	.DrawerWindow.show {
		transform: scale(1, 1) translateX(0%);
		opacity: 1;
		pointer-events: all;
	}

	.DrawerClose {
		position: absolute;
		width: 40vw;
		height: 100vh;
		right: 0;
		top: 0;
		color: transparent;
		padding-bottom: 30rpx;
		display: flex;
		align-items: flex-end;
		justify-content: center;
		background-image: linear-gradient(90deg, rgba(0, 0, 0, 0.01), rgba(0, 0, 0, 0.6));
		letter-spacing: 5px;
		font-size: 50rpx;
		opacity: 0;
		pointer-events: none;
		transition: all 0.4s;
	}

	.DrawerClose.show {
		opacity: 1;
		pointer-events: all;
		width: 15vw;
		color: #fff;
	}

	.DrawerPage .cu-bar.tabbar .action button.icon {
		width: 64rpx;
		height: 64rpx;
		line-height: 64rpx;
		margin: 0;
		display: inline-block;
	}

	.DrawerPage .cu-bar.tabbar .action .cu-avatar {
		margin: 0;
	}

	.DrawerPage .nav {
		flex: 1;
	}

	.DrawerPage .nav .cu-item.cur {
		border-bottom: 0;
		position: relative;
	}

	.DrawerPage .nav .cu-item.cur::after {
		content: "";
		width: 10rpx;
		height: 10rpx;
		background-color: currentColor;
		position: absolute;
		bottom: 10rpx;
		border-radius: 10rpx;
		left: 0;
		right: 0;
		margin: auto;
	}

	.DrawerPage .cu-bar.tabbar .action {
		flex: initial;
	}
</style>